
function [ mad ] = MAD( rPortfolio, rIndex, beta )
%MAD Summary of this function goes here
%   Detailed explanation goes here
    [m n] = size(rPortfolio);
    if (length(beta)==1)
        for i=1:n
            mad = sum(abs(rPortfolio(:,i) - rIndex*beta))/m; 
        end
    else
        for i=1:n
            mad = sum(abs(rPortfolio(:,i) - rIndex(i)*beta(i)))/m; 
        end
    end

end

